package main.java.thread;

import java.util.Scanner;

/**
 * sleep阻塞
 * 线程提供了一个静态方法
 * static void sleep(long millis) throws InterruptedException
 * 该方法可以让执行这个方法的线程进入阻塞状态，并且阻塞时间是millis毫秒，超时后会回到runnable状态等待并发
 */
public class SleepDemo {
    public static void main(String[] args) {
        System.out.println("main start...");
        Scanner sc = new Scanner(System.in);
        int time = sc.nextInt();
        //int j = time;
        try{
            while (time>0){
                Thread.sleep(1000);
                System.out.println("倒计时 " + time-- + " s");
            }
            //Thread.sleep(1000);
            System.out.println("倒计时结束");
        }catch (InterruptedException e){
            e.printStackTrace();
        }
        System.out.println("main end...");
    }
}
